package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SysAudit;
import com.ruoyi.system.service.ISysAuditService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 审计基础Controller
 * 
 * @author ruoyi
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/sys/audit")
public class SysAuditController extends BaseController
{
    @Autowired
    private ISysAuditService sysAuditService;

    /**
     * 查询审计基础列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysAudit sysAudit)
    {
        startPage();
        List<SysAudit> list = sysAuditService.selectSysAuditList(sysAudit);
        return getDataTable(list);
    }

    /**
     * 导出审计基础列表
     */
    @Log(title = "审计基础", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAudit sysAudit)
    {
        List<SysAudit> list = sysAuditService.selectSysAuditList(sysAudit);
        ExcelUtil<SysAudit> util = new ExcelUtil<SysAudit>(SysAudit.class);
        util.exportExcel(response, list, "审计基础数据");
    }

    /**
     * 获取审计基础详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysAuditService.selectSysAuditById(id));
    }

    /**
     * 新增审计基础
     */
    @Log(title = "审计基础", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAudit sysAudit)
    {
        return toAjax(sysAuditService.insertSysAudit(sysAudit));
    }

    /**
     * 修改审计基础
     */
    @Log(title = "审计基础", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAudit sysAudit)
    {
        return toAjax(sysAuditService.updateSysAudit(sysAudit));
    }

    /**
     * 删除审计基础
     */
    @Log(title = "审计基础", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysAuditService.deleteSysAuditByIds(ids));
    }
}
